package nf;

import nf.graph.Graph;
import java.util.EventListener;
import java.util.Collection;
import java.util.HashSet;

public interface GameRunListener extends EventListener
{
	public void runStarted(GameRunner runner);
	public void stepStarted(GameRunner runner);
	public void stepFinished(GameRunner runner);
	public void equilibriumReached(GameRunner runner);
	
	public static class Adapter implements GameRunListener
	{
		public void runStarted(GameRunner runner)
		{
		}
		
		public void stepStarted(GameRunner runner)
		{
		}
		
		public void stepFinished(GameRunner runner)
		{
		}
		
		public void equilibriumReached(GameRunner runner)
		{
		}
	}
	
	public static class Set extends HashSet<GameRunListener>
	{
		public Set()
		{
			super();
		}
		
		public Set(Collection<GameRunListener> existing)
		{
			super(existing);
		}
		
		public void runStarted(GameRunner runner)
		{
			for (GameRunListener l : this)
				l.runStarted(runner);
		}
		
		public void stepStarted(GameRunner runner)
		{
			for (GameRunListener l : this)
				l.stepStarted(runner);
		}
		
		public void stepFinished(GameRunner runner)
		{
			for (GameRunListener l : this)
				l.stepFinished(runner);
		}
		
		public void equilibriumReached(GameRunner runner)
		{
			for (GameRunListener l : this)
				l.equilibriumReached(runner);
		}
	}
}
